package com.mbyte.easy.security.entity;

import java.util.Collection;
import java.util.Date;
import java.util.List;

import com.mbyte.easy.qcbyclass.entity.QcbyClass;
import com.mbyte.easy.student.entity.Student;
import com.mbyte.easy.teacher.entity.Teacher;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

public class SysUser implements UserDetails {
    @Override
    public String toString() {
        return "SysUser{" +
                "id=" + id +
                ", createtime=" + createtime +
                ", password='" + password + '\'' +
                ", updatetime=" + updatetime +
                ", username='" + username + '\'' +
                ", available=" + available +
                ", email='" + email + '\'' +
                ", tel='" + tel + '\'' +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", sexType=" + sexType +
                ", roles=" + roles +
                ", sys_user_roles=" + sys_user_roles +
                ", t_teacher=" + t_teacher +
                ", t_student=" + t_student +
                ", t_qcby_class=" + t_qcby_class +
                '}';
    }

    private static final long serialVersionUID = 1L;

    /**
     *
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column sys_user.id
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    private Long id;

    /**
     *
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column sys_user.createtime
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    private Date createtime;

    /**
     *
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column sys_user.password
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    private String password;

    /**
     *
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column sys_user.updatetime
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    private Date updatetime;

    /**
     *
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column sys_user.username
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    private String username;

    /**
     *
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column sys_user.available
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    private Boolean available;

    /**
     *
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column sys_user.email
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    private String email;

    /**
     *
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column sys_user.tel
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    private String tel;

    private String name;
    private Integer age;
    /**
     *
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column sys_user.sex_type
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    private Integer sexType;

    private List<SysRole> roles;

    public List<SysRole> getRoles() {
        return roles;
    }

    private SysUserRoles sys_user_roles;

    private Teacher t_teacher;

    private Student t_student;

    private QcbyClass t_qcby_class;

    public QcbyClass getT_qcby_class() {
        return t_qcby_class;
    }

    public void setT_qcby_class(QcbyClass t_qcby_class) {
        this.t_qcby_class = t_qcby_class;
    }

    public Student getT_student() {
        return t_student;
    }

    public void setT_student(Student t_student) {
        this.t_student = t_student;
    }

    public Teacher getT_teacher() {
        return t_teacher;
    }

    public void setT_teacher(Teacher t_teacher) {
        this.t_teacher = t_teacher;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public SysUserRoles getSys_user_roles() {
        return sys_user_roles;
    }

    public void setSys_user_roles(SysUserRoles sys_user_roles) {
        this.sys_user_roles = sys_user_roles;
    }

    public void setRoles(List<SysRole> roles) {
        this.roles = roles;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column sys_user.id
     *
     * @return the value of sys_user.id
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    public Long getId() {
        return id;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column sys_user.id
     *
     * @param id
     *            the value for sys_user.id
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column sys_user.createtime
     *
     * @return the value of sys_user.createtime
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    public Date getCreatetime() {
        return createtime;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column sys_user.createtime
     *
     * @param createtime
     *            the value for sys_user.createtime
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    public void setCreatetime(Date createtime) {
        this.createtime = createtime;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column sys_user.password
     *
     * @return the value of sys_user.password
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    @Override
    public String getPassword() {
        return password;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column sys_user.password
     *
     * @param password
     *            the value for sys_user.password
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column sys_user.updatetime
     *
     * @return the value of sys_user.updatetime
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    public Date getUpdatetime() {
        return updatetime;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column sys_user.updatetime
     *
     * @param updatetime
     *            the value for sys_user.updatetime
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    public void setUpdatetime(Date updatetime) {
        this.updatetime = updatetime;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column sys_user.username
     *
     * @return the value of sys_user.username
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    @Override
    public String getUsername() {
        return username;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column sys_user.username
     *
     * @param username
     *            the value for sys_user.username
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column sys_user.available
     *
     * @return the value of sys_user.available
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    public Boolean getAvailable() {
        return available;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column sys_user.available
     *
     * @param available
     *            the value for sys_user.available
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    public void setAvailable(Boolean available) {
        this.available = available;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column sys_user.email
     *
     * @return the value of sys_user.email
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    public String getEmail() {
        return email;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column sys_user.email
     *
     * @param email
     *            the value for sys_user.email
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column sys_user.tel
     *
     * @return the value of sys_user.tel
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    public String getTel() {
        return tel;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column sys_user.tel
     *
     * @param tel
     *            the value for sys_user.tel
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    public void setTel(String tel) {
        this.tel = tel;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column sys_user.sex_type
     *
     * @return the value of sys_user.sex_type
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    public Integer getSexType() {
        return sexType;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column sys_user.sex_type
     *
     * @param sexType
     *            the value for sys_user.sex_type
     *
     * @mbg.generated Mon Jul 17 14:46:14 CST 2017
     */
    public void setSexType(Integer sexType) {
        this.sexType = sexType;
    }



    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
//        List<GrantedAuthority> auths = new ArrayList<GrantedAuthority>();
//        List<SysRole> roles = this.getRoles();
//        for (SysRole role : roles) {
//            for (SysResource resource : role.getResources()) {
//                if (resource.getPermission() != "" && resource.getPermission() != null) {
//                    auths.add(new SimpleGrantedAuthority(resource.getPermission()));// 将用户的角色名作为权限
//                }
//            }
//        }
//        return auths;
        return null;
    }

    @Override
    public boolean isAccountNonExpired() {
        // TODO Auto-generated method stub
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        // TODO Auto-generated method stub
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        // TODO Auto-generated method stub
        return true;
    }

    @Override
    public boolean isEnabled() {
        // TODO Auto-generated method stub
        return true;
    }
}